<template>
    <div class="mui-numbox" data-numbox-min='1' style="height:25px;">
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input id="test" class="mui-input-numbox" type="number" :value="initcount" @change="countChanged" ref="numbox" readonly/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>
<script>
import mui from '../../lib/mui/js/mui.min.js'
    export default {
        data (){
            return {};
        },
        mounted(){
            //初始化数字框
            mui('.mui-numbox').numbox();
            console.log(this.max);
        },
        methods:{
            countChanged(){
                // 当触发这个方法的时候，证明选择的商品数量改变了
                console.log(this.$refs.numbox.values);
                // 当数量改变，应该把数量同步到 store 中去
                this.$state.commit("updateGoodsCount",{id:this.id,count:parseInt(  this.$refs.numbox.values)})
            }
        },
        props:["initcount","id"]
    }
</script>

<style lang="scss" scoped>

</style>
